package com.yantong.controller.api;

import com.yantong.pojo.Industry;
import com.yantong.pojo.IndustryBrand;
import com.yantong.service.IndustryBrandService;
import com.yantong.service.IndustryService;
import com.yantong.controller.BaseController;
import com.yantong.result.ResultVo;
import com.yantong.utils.PageUtils;
import com.yantong.pojo.Member;
import com.yantong.annotation.LoginUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 行业品牌相关接口
 *
 */
@Api(tags = "行业和品牌相关接口")
@Controller
@RequestMapping("/wxapi/industryBrand")
public class ApiIndustryBrandController extends BaseController {

	@Autowired
	private IndustryBrandService industryBrandService;
	@Autowired
	private IndustryService industryService;


	@ApiOperation(value = "行业列表查询")
	@ResponseBody
	@GetMapping("/getIndustryList")
	public ResultVo getIndustryList(@LoginUser Member member, Integer offset, Integer limit){
		if(offset == null){
			offset = 0;
		}
		if(limit == null){
			limit = 10;
		}
		ResultVo resultVo = new ResultVo();
		PageUtils<Industry> pageUtils = new PageUtils<>();
		Industry industry = new Industry();
		industry.setCentreId(member.getCentreId());
		pageUtils = industryService.listIndustry(industry,offset,limit);
		resultVo.put("data",pageUtils);
		resultVo.put("code",0);
		return resultVo;
	}


	@ApiOperation(value = "行业品牌列表查询")
	@ResponseBody
	@GetMapping("/getIndustryBrandList")
	public ResultVo getIndustryBrandList(@LoginUser Member member,Long industryId, Integer offset, Integer limit){
		if(offset == null){
			offset = 0;
		}
		if(limit == null){
			limit = 10;
		}
		ResultVo resultVo = new ResultVo();
		PageUtils<IndustryBrand> pageUtils = new PageUtils<>();
		IndustryBrand industryBrand = new IndustryBrand();
		industryBrand.setCentreId(member.getCentreId());
		industryBrand.setIndustryId(industryId);
		pageUtils = industryBrandService.listIndustryBrand(industryBrand,offset,limit);
		resultVo.put("data",pageUtils);
		resultVo.put("code",0);
		return resultVo;
	}


}
